<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tk="http://www.qdocuments.net" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="tk msxsl">
  <xsl:import href="DetailListFrame_Trans.xslt"/>
  <xsl:import href="ListItems.xslt"/>
  <xsl:template name="tk:SingleDetailListPage">
    <xsl:param name="Table"/>
    <xsl:param name="Source"/>
    <xsl:param name="DListRefParams"/>
    <xsl:variable name="FieldList">
      <xsl:for-each select="$Table/tk:Field[tk:List]">
        <xsl:sort select="tk:List/Order"/>
        <xsl:copy-of select="."/>
      </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="AllFieldList" select="$Table/tk:Field"/>
    <xsl:variable name="FieldNodes" select="msxsl:node-set($FieldList)/*"/>
    <tr id="td{$Table/@TableName}">
      <xsl:if test="position() != 1">
        <xsl:attribute name="style">display: none</xsl:attribute>
      </xsl:if>
      <td style="border-right: 1px solid #6794CB; border-bottom: 1px solid #6794CB; border-top: 1px solid #D9E4F2; border-left: 1px solid #D9E4F2; padding: 8px">
        <table width="100%" border="0" cellpadding="1" cellspacing="1" class="listtb">
          <tr>
            <xsl:call-template name="tk:OperationHead"/>
            <xsl:apply-templates select="$FieldNodes" mode="tk:Head"/>
          </tr>
          <xsl:variable name="Data" select="$tk:Toolkit/*[local-name()=$Table/@TableName]"/>
          <xsl:choose>
            <xsl:when test="count($Data) &gt; 0">
              <xsl:for-each select="$Data">
                <xsl:call-template name="tk:DetailRecord">
                  <xsl:with-param name="FieldList" select="$FieldNodes"/>
                  <xsl:with-param name="AllFieldList" select="$AllFieldList"/>
                  <xsl:with-param name="Source" select="$Source"/>
                  <xsl:with-param name="DListRefParams" select="$DListRefParams"/>
                </xsl:call-template>
              </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
              <xsl:copy-of select="$tk:NoRecord"/>
            </xsl:otherwise>
          </xsl:choose>
        </table>
        <table width="100%" border="0" cellpadding="1" cellspacing="0">
          <tr>
            <td align="right">
              <xsl:call-template name="tk:DetailButton">
                <xsl:with-param name="Table" select="$Table"/>
                <xsl:with-param name="Source" select="$Source"/>
                <xsl:with-param name="DListRefParams" select="$DListRefParams"/>
              </xsl:call-template>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </xsl:template>
  <xsl:template name="tk:DetailTitlePage">
    <xsl:param name="Table"/>
    <td width="1%" height="22" nowrap="nowrap" onClick="showtb('th{$Table/@TableName}','td{$Table/@TableName}')" id="th{$Table/@TableName}">
      <xsl:attribute name="background"><xsl:choose><xsl:when test="position() != 1">../images/lbx.gif</xsl:when><xsl:otherwise>../images/lby.gif</xsl:otherwise></xsl:choose></xsl:attribute>
      <a style="cursor: hand">
        <xsl:value-of select="$Table/@TableDesc"/>
      </a>
    </td>
  </xsl:template>
  <xsl:template match="tk:Field" mode="tk:Head">
    <xsl:call-template name="tk:NoSortColHead">
      <xsl:with-param name="Title" select="tk:DisplayName"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template name="tk:DetailRecord">
    <xsl:param name="FieldList"/>
    <xsl:param name="AllFieldList"/>
    <xsl:param name="Source"/>
    <xsl:param name="DListRefParams"/>
    <tr valign="top" class="td-bg" onmouseover="this.style.backgroundColor = '#F9F9F0';" onmouseout="this.style.backgroundColor = '';">
      <xsl:call-template name="tk:DListOperation">
        <xsl:with-param name="FieldList" select="$AllFieldList"/>
        <xsl:with-param name="DataRecord" select="."/>
        <xsl:with-param name="Source" select="$Source"/>
        <xsl:with-param name="DListRefParams" select="$DListRefParams"/>
      </xsl:call-template>
      <xsl:apply-templates select="$FieldList" mode="tk:DetailItem">
        <xsl:with-param name="DataRecord" select="."/>
        <xsl:with-param name="FieldList" select="$AllFieldList"/>
        <xsl:with-param name="Source" select="$Source"/>
        <xsl:with-param name="DListRefParams" select="$DListRefParams"/>
      </xsl:apply-templates>
    </tr>
  </xsl:template>
  <xsl:template match="tk:Field" mode="tk:DetailItem">
    <xsl:param name="DataRecord"/>
    <xsl:param name="FieldList"/>
    <xsl:param name="Source"/>
    <xsl:param name="DListRefParams"/>
    <xsl:call-template name="tk:DisplayListItem">
      <xsl:with-param name="DataRecord" select="$DataRecord"/>
      <xsl:with-param name="FieldList" select="$FieldList"/>
      <xsl:with-param name="Source" select="$Source"/>
      <xsl:with-param name="DListRefParams" select="$DListRefParams"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template name="tk:DListOperation">
    <xsl:param name="FieldList"/>
    <xsl:param name="DataRecord"/>
    <xsl:param name="Source"/>
    <xsl:param name="DListRefParams"/>
    <xsl:choose>
      <xsl:when test="$Source!=''">
        <xsl:call-template name="tk:Operation">
          <xsl:with-param name="FieldList" select="$FieldList"/>
          <xsl:with-param name="DataRecord" select="."/>
          <xsl:with-param name="Source" select="$Source"/>
          <xsl:with-param name="DListRefParams" select="$DListRefParams"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="tk:EmptyOperation"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>
